package org.example.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.pojo.DLeave;
import org.example.pojo.select.DItemSelect;
import org.example.pojo.select.DLeaveSelect;
import org.example.service.DLeaveService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("leave")
@Tag(name = "请假记录API",description = "Leave Controller")
public class LeaveController {

    @Autowired
    private DLeaveService dLeaveService;

    /**
     * 查询所有请假记录
     * @param dLeaveSelect
     * @return
     */
    @Operation(summary = "获取请假记录")
    @PostMapping("/selectAll")
    public Result<Map> SelectAll(@RequestBody DLeaveSelect dLeaveSelect){
        return dLeaveService.SelectLeaves(dLeaveSelect);
    }

    /**
     * 添加请假记录
     * @param dLeaveList
     * @return
     */
    @Operation(summary = "增加请假记录")
    @PostMapping("/addLeave")
    public Result<Map> AddLeave(@RequestBody List<DLeaveSelect> dLeaveList){
        return dLeaveService.AddLeave(dLeaveList);
    }

    /**
     * 删除请假记录
     * @param dLeaveList
     * @return
     */
    @Operation(summary = "删除请假记录")
    @PostMapping("/deleteLeave")
    public Result<Map> DeleteLeave(@RequestBody List<DLeave> dLeaveList){
        return dLeaveService.DeleteLeave(dLeaveList);
    }
}
